package Properties;

import org.junit.Test;

import java.io.*;
import java.util.Properties;

public class demo01
{
	@Test
	public void test() throws IOException
	{
		Properties prop = new Properties();
		//读取properties配置文件
//		prop.load(new FileInputStream("./test.properties"));
//		Set<String> setKeys = prop.stringPropertyNames();
//		for(String key : setKeys)
//		{
//			System.out.println(key + ":" + prop.getProperty(key));
//		}
		prop.setProperty("username", "root");
		prop.setProperty("password", "123456");
		//向properties文件写入
		prop.store(new FileOutputStream("test.properties"), "备注描述");
	}
}
